{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 导包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>样地号</th>\n",
       "      <th>立木类型</th>\n",
       "      <th>样木号</th>\n",
       "      <th>树种代码</th>\n",
       "      <th>检尺类型</th>\n",
       "      <th>直径</th>\n",
       "      <th>材质等级</th>\n",
       "      <th>材积式</th>\n",
       "      <th>材积</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>6166</td>\n",
       "      <td>1</td>\n",
       "      <td>61</td>\n",
       "      <td>180</td>\n",
       "      <td>11</td>\n",
       "      <td>122</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>6353</td>\n",
       "      <td>1</td>\n",
       "      <td>45</td>\n",
       "      <td>140</td>\n",
       "      <td>14</td>\n",
       "      <td>61</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>6794</td>\n",
       "      <td>1</td>\n",
       "      <td>69</td>\n",
       "      <td>140</td>\n",
       "      <td>1</td>\n",
       "      <td>50</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>7188</td>\n",
       "      <td>1</td>\n",
       "      <td>92</td>\n",
       "      <td>240</td>\n",
       "      <td>16</td>\n",
       "      <td>125</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>6794</td>\n",
       "      <td>1</td>\n",
       "      <td>20</td>\n",
       "      <td>330</td>\n",
       "      <td>17</td>\n",
       "      <td>130</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>681</td>\n",
       "      <td>1</td>\n",
       "      <td>22</td>\n",
       "      <td>310</td>\n",
       "      <td>1</td>\n",
       "      <td>133</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>10861</td>\n",
       "      <td>3</td>\n",
       "      <td>29</td>\n",
       "      <td>200</td>\n",
       "      <td>1</td>\n",
       "      <td>92</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8064</td>\n",
       "      <td>1</td>\n",
       "      <td>48</td>\n",
       "      <td>260</td>\n",
       "      <td>11</td>\n",
       "      <td>105</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1344</td>\n",
       "      <td>1</td>\n",
       "      <td>54</td>\n",
       "      <td>140</td>\n",
       "      <td>1</td>\n",
       "      <td>153</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>3167</td>\n",
       "      <td>1</td>\n",
       "      <td>54</td>\n",
       "      <td>240</td>\n",
       "      <td>1</td>\n",
       "      <td>64</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     样地号  立木类型  样木号  树种代码  检尺类型   直径  材质等级  材积式  材积\n",
       "0   6166     1   61   180    11  122     0    0  53\n",
       "1   6353     1   45   140    14   61     0    0   7\n",
       "2   6794     1   69   140     1   50     0    0   4\n",
       "3   7188     1   92   240    16  125     0    0  53\n",
       "4   6794     1   20   330    17  130     0    0  54\n",
       "5    681     1   22   310     1  133     0    0  73\n",
       "6  10861     3   29   200     1   92     0    0  23\n",
       "7   8064     1   48   260    11  105     0    0  33\n",
       "8   1344     1   54   140     1  153     0    0  87\n",
       "9   3167     1   54   240     1   64     0    0   9"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "csv_df = pd.read_csv(r'./使用数据/样木库.csv',encoding='utf_8_sig')\n",
    "csv_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>经营类型</th>\n",
       "      <th>土地所有权</th>\n",
       "      <th>流域名称</th>\n",
       "      <th>四旁树株数</th>\n",
       "      <th>灌木平均高</th>\n",
       "      <th>散生木株数</th>\n",
       "      <th>土地利用现状地类</th>\n",
       "      <th>坡向</th>\n",
       "      <th>人工林生长等级</th>\n",
       "      <th>国家级公益林保护等级</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>243</th>\n",
       "      <td>31.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1.2</td>\n",
       "      <td>121</td>\n",
       "      <td>201.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>230</th>\n",
       "      <td>31.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>139</td>\n",
       "      <td>201.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>181</th>\n",
       "      <td>31.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1.5</td>\n",
       "      <td>601</td>\n",
       "      <td>201.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>22.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0</td>\n",
       "      <td>301.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>12.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0</td>\n",
       "      <td>301.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>13.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0</td>\n",
       "      <td>301.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>164</th>\n",
       "      <td>31.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1.2</td>\n",
       "      <td>241</td>\n",
       "      <td>201.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96</th>\n",
       "      <td>31.0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1.3</td>\n",
       "      <td>93</td>\n",
       "      <td>201.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>193</th>\n",
       "      <td>31.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2176</td>\n",
       "      <td>201.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>125</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>322</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1005.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     经营类型  土地所有权  流域名称  四旁树株数  灌木平均高  散生木株数  土地利用现状地类   坡向  人工林生长等级  \\\n",
       "243  31.0      1     1      0    1.2    121     201.0  4.0      NaN   \n",
       "230  31.0      1     1      0    1.0    139     201.0  8.0      NaN   \n",
       "181  31.0      1     1      0    1.5    601     201.0  3.0      NaN   \n",
       "4    22.0      1     1      0    1.5      0     301.0  3.0      NaN   \n",
       "57   12.0      1     1      0    1.5      0     301.0  4.0      NaN   \n",
       "22   13.0      1     1      0    1.5      0     301.0  3.0      2.0   \n",
       "164  31.0      1     1      0    1.2    241     201.0  5.0      NaN   \n",
       "96   31.0      2     1      0    1.3     93     201.0  9.0      NaN   \n",
       "193  31.0      1     1      0    1.0   2176     201.0  8.0      NaN   \n",
       "125   NaN      1     1    322    0.0      0    1005.0  9.0      NaN   \n",
       "\n",
       "     国家级公益林保护等级  \n",
       "243         NaN  \n",
       "230         NaN  \n",
       "181         NaN  \n",
       "4           NaN  \n",
       "57          2.0  \n",
       "22          NaN  \n",
       "164         NaN  \n",
       "96          NaN  \n",
       "193         NaN  \n",
       "125         NaN  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "excel_df = pd.read_excel(r'./使用数据/小班属性表.xls')\n",
    "sam_excel_df = excel_df.sample(10).sample(10,axis=1)\n",
    "sam_excel_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "csv_df.to_csv(r'./输出数据/样木库.csv',encoding='utf_8_sig',index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "sam_excel_df.to_excel(r'./输出数据/属性表.xls',index=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
